<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>统计报表-国家</title>

    <!-- bootstrap -->
    <link href="__CSS__/bootstrap/bootstrap.css" rel="stylesheet" />

    <!-- libraries -->
    <!-- <link href="css/libs/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" /> -->
    <link href="__CSS__/libs/font-awesome.css" type="text/css" rel="stylesheet" />

    <!-- global styles -->
    <link rel="stylesheet" type="text/css" href="__CSS__/compiled/layout.css">
    <link rel="stylesheet" type="text/css" href="__CSS__/compiled/elements.css">

    <!-- this page specific styles -->
    <link rel="stylesheet" type="text/css" href="__CSS__/libs/bootstrap-wizard.css">
    <link rel="stylesheet" href="__CSS__/libs/select2.css" type="text/css" />

    <!-- Favicon -->
    <!--<link type="image/x-icon" href="favicon.png" rel="shortcut icon"/>-->

    <!-- google font libraries -->
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,300|Titillium+Web:200,300,400' rel='stylesheet' type='text/css'>

    <script>
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

        ga('create', 'UA-49262924-1', 'phoonio.com');
        ga('send', 'pageview');

    </script>
</head>
<body>
<!--head-->
{include file="pub/head"/}

<div class="container" role="main">
    <div class="row">

        <!--left-->
        {include file="pub/left"/}

        <div class="col-md-10" id="content-wrapper">
            <!--<h2 class="pull-left">Last orders</h2>-->
            <div class="row">
                <div class="col-lg-12">
                    <!--<div class="row">
                        <div class="col-lg-12">-->
                    <div class="main-box">
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <div class="x_panel">
                                <div class="x_title pull-right">
                                    <label style="font-size: 24px;color: #0e90d2;width: 100px;">美元汇率</label>
                                    <input type="text" name="rate" value="" id="rate" onchange="newCharts()" placeholder="默认:6.5" style="width: 100px;height: 36px;line-height: 36px;border-radius: 5px;">
                                </div>
                                <div class="x_content">

                                    <div  class="col-md-12 col-sm-12 col-xs-12">
                                        <div class="x_panel tile">
                                            <div class="x_content">
                                                <table class="">
                                                    <tr>
                                                        <th class="col-lg-8 col-md-8 col-sm-8 col-xs-12">
                                                            <p style="font-size: 18px;">订单总额对比图-按国家分</p>
                                                            <hr/>
                                                        </th>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <canvas id="graph" class="canvasDoughnut" width="1000" height="600" style="margin: 15px 10px 10px 0;" ></canvas>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>

            <!--</div>
        </div>-->
        </div>
    </div>
</div>
<!--foot-->
{include file="pub/foot"/}

<!-- global scripts -->
<script src="__JS__/jquery.js"></script>

<script src="__JS__/bootstrap.min.js"></script>

<!-- this page specific scripts -->
<script src="__JS__/bootstrap-wizard.js"></script>
<script src="__JS__/select2.min.js"></script>

<!-- theme scripts -->
<script src="__JS__/scripts.js"></script>
<script src="__JS__/echarts.js"></script>

<script>
    var myChart = echarts.init(document.getElementById('graph'));

    defaultRate(myChart)
    function defaultRate(myChart) {
        var graphS = '{$graphyS}';
        //console.log(graphS)
        graphS = JSON.parse(graphS);
        //console.log(graphS)
        changeRate(graphS, myChart);
    }
    //changeRate()
    function changeRate(graphS, myChart) {
        /*for state*/
        var state = [];
        var dataS = [];
        for(var i=0;i<graphS.length;i++){
            dataS[i] = {value:graphS[i]['value'],name:graphS[i]['state']}
            state[i] = graphS[i]['state']
        }
        optionS = {
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                left: 'left',
                data: state
            },
            series : [
                {
                    name: '订单总额占比',
                    type: 'pie',
                    radius : '46%',
                    center: ['46%', '35%'],
                    label:{            //饼图图形上的文本标签
                        normal:{
                            show:true,
                            textStyle : {
                                fontWeight : 300 ,
                                fontSize : 14    //文字的字体大小
                            },
                            formatter:'{b}:{d}%'
                            //formatter:'{b}:{c}￥'
                        }
                    },
                    data:dataS,
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(optionS);
    }

    function newCharts() {
        //改变汇率
        var rate = $('#rate').val();
        //console.log(rate)
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "{:url('Order/jsonGraphS')}",//url
            data: {'rate':rate},
            success: function (result) {
                //console.log(result)
                var graph = result;
                changeRate(graph, myChart);
            },
            error:function (result) {
                //console.log('error'+result)
                alert('服务出错')
            }
        });
    }

</script>
</body>
</html>